package com.borko.healthcare.persistence.hibernate.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.borko.healthcare.entities.beans.UserDetailsBean;
import com.borko.healthcare.entities.interfaces.UserDetails;

public class UserDetailsDAOImpl extends HibernateDaoSupport implements UserDetailsDAO {
	
	private void createOrUpdate(UserDetails userDetails) {
		getHibernateTemplate().saveOrUpdate(userDetails);
	}

	public void create(UserDetails userDetails) {
		createOrUpdate(userDetails);
	}

	public void delete(UserDetails userDetails) {
		getHibernateTemplate().delete(userDetails);
	}

	public List<UserDetails> retrive() {
		return getHibernateTemplate().loadAll(UserDetails.class);
	}

	public void update(UserDetails userDetails) {
		getHibernateTemplate().saveOrUpdate(userDetails);
	}
	
	public UserDetails getUserDetails(int id) {
		return getHibernateTemplate().get(UserDetailsBean.class, id);
	}

}
